package com.mapproject.industrymap.utils;

import java.security.MessageDigest;

public class EncodeMd5 {
    public   String MD5(String data) throws Exception {
        //返回实现指定摘要算法的MessageDigest对象
        MessageDigest md = MessageDigest.getInstance("MD5");
        //使用指定的字节更新摘要
        md.update(data.getBytes("UTF-8"));
        //通过执行最后的操作（如填充）来完成哈希计算
        byte[] array = md.digest();
        StringBuilder result = new StringBuilder();
        //对哈希数进行密码散列计算
        for (byte item : array) {
            result.append(Integer.toHexString((item & 0xFF)|0x100).substring(1, 3));
        }
        return result.toString().toUpperCase();
    }

}
